package com.gitee.ywj1352.zk;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

/**
 * @author wenjie.yang on 2019/6/18.
 */
public class App {

    public static void main(String[] args) throws IOException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for(int i = 0 ;i<10;i++){
            new Thread(()->{
                try{
                    countDownLatch.await();
                    DistributedLock distributedLock = new DistributedLock();
                    distributedLock.lock();
                    Thread.sleep(100);
                    distributedLock.unlock();
                }catch (Exception e){
                    e.printStackTrace();
                }
            },"tread"+i).start();
            countDownLatch.countDown();
        }
        System.in.read();
    }
}

